<?php
	namespace Home\Controller;
	use Think\Controller;
	use Think\Verify;
	
	class LoginController extends Controller
	{
		public function index()
		{
			
			$this->display();
		}
		public function login()
		{
			//获取信息
			$userName=$_POST['userName'];
			$password=$_POST['password'];
			$checkCode=$_POST['checkCode'];
			//比对验证码
			$verify=new Verify();
			$r=$verify->check("$checkCode");
			
			if($r)
			{
				$result=M('userinfo')->where("'{$userName}'=userName and '{$password}'=password")->find();
				//$result=M('manager')->find($_POST);
				//验证
				if($result==NULL)
				{
					$this->success("登录失败，用户名或密码错误！",__APP__."/Login/index");
				}
				else
				{
					$_SESSION["usersk"]=$result;
					$this->success("登录成功！",__APP__."/index/index");
					
				}
			}
			else 
			{
				$this->success("验证码输入有误！",__APP__."/Login/index");	
			}
			
		}
		public function verify()
		{
			$verify=new Verify();
			$verify->length=3;
			$verify->fontSize=30;
			$verify->entry();
		}
		//退出登录
		public function outLogin()
		{
			unset($_SESSION['usersk']);
			$this->success("退出成功",__APP__."/index/index");
		}
	}
?>